import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 操作日志信息 */
export interface Log {
          id: number; // 主键
          operateTime?: string | Dayjs; // 操作时间
          userId: number; // 用户id
          userName: string; // 用户姓名
          userIp: string; // 用户操作ip
          userAgent: string; // 操作设备
          contentTitle?: string; // 操作标题
          content?: string; // 操作详情
  }

// 操作日志 API
export const LogApi = {
  // 查询操作日志分页
  getLogPage: async (params: any) => {
    return await request.get({ url: `/operation/log/page`, params })
  },

  // 查询操作日志详情
  getLog: async (id: number) => {
    return await request.get({ url: `/operation/log/get?id=` + id })
  },

  // 新增操作日志
  createLog: async (data: Log) => {
    return await request.post({ url: `/operation/log/create`, data })
  },

  // 修改操作日志
  updateLog: async (data: Log) => {
    return await request.put({ url: `/operation/log/update`, data })
  },

  // 删除操作日志
  deleteLog: async (id: number) => {
    return await request.delete({ url: `/operation/log/delete?id=` + id })
  },

  /** 批量删除操作日志 */
  deleteLogList: async (ids: number[]) => {
    return await request.delete({ url: `/operation/log/delete-list?ids=${ids.join(',')}` })
  },

  // 导出操作日志 Excel
  exportLog: async (params) => {
    return await request.download({ url: `/operation/log/export-excel`, params })
  },
}